package com.david.IfaceAutoTest.controller;

import com.david.IfaceAutoTest.entity.ProjectModel;
import com.david.IfaceAutoTest.service.ProjectModelService;
import io.swagger.annotations.*;
import com.david.IfaceAutoTest.entity.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目子模块 控制层
 *
 * @author david
 * @since 2021-12-14
 */
@RestController
@Api(tags = "project_model接口")
@RequestMapping("/IfaceAutoTest/project-model")
public class ProjectModelController {

    private final ProjectModelService projectmodelservice;

    @Autowired
    public ProjectModelController(ProjectModelService projectmodelservice) {
        this.projectmodelservice = projectmodelservice;
    }

    @GetMapping("/list")
    @ApiOperation(value = "项目子模块列表查询", notes = "list")
    public CommonResult<Object> list() {
        return CommonResult.success(projectmodelservice.list());
    }

    @GetMapping("/get")
    @ApiOperation(value = "项目子模块详情查询", notes = "get")
    public CommonResult<Object> get(Integer id) {
        return CommonResult.success(projectmodelservice.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "项目子模块保存", notes = "save")
    public CommonResult<Object> save(ProjectModel projectmodel) {
        return CommonResult.success(projectmodelservice.save(projectmodel));
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "项目子模块删除", notes = "delete")
    public CommonResult<Object> delete(Integer id) {
        projectmodelservice.removeById(id);
        return CommonResult.success();
    }
}
